<include file="Public:header" />
<form  method="post" class="definewidth m20" id="user-form">
    <input type="hidden" value="{$user['user_id']}" name="user_id" />
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">登录名</td>
            <td><input type="text" name="name" value="{$user['name']}"/></td>
        </tr>
        <input type="hidden" name="password" value="{$user['password']}"/>
        <input type="hidden" name="repassword" value="{$user['password']}"/>
        <!-- <tr>
            <td class="tableleft">密码</td>
            <td><input type="password" name="password" value="{$user['password']}"/></td>
        </tr>
        <tr>
            <td class="tableleft">确认密码</td>
            <td><input type="password" name="repassword" value="{$user['password']}"/></td>
        </tr> -->
        <tr>
            <td class="tableleft">真实姓名</td>
            <td><input type="text" name="nickname" value="{$user['nickname']}"/></td>
        </tr>

        <tr>
            <td class="tableleft">性别</td>
            <td>
                <input type="radio" name="gender" value="1" <if condition="$user['gender'] eq 1"> checked </if> /> 男
                <input type="radio" name="gender" value="2" <if condition="$user['gender'] eq 2"> checked </if> /> 女
            </td>
        </tr>
        <tr>
            <td class="tableleft">出生年月</td>
            <td>
                <input type="date" name="borth" value="{$user['borth']|date='Y-m-d',###}"/>
            </td>
        </tr>
        <!-- <tr>
            <td class="tableleft">角色</td>
            <td>
                <select name="role_id">
                    <foreach name="role_list" item="r_val">
                        <option value="{$r_val['role_id']}" <if condition="$user['role_id'] eq $r_val['role_id']"> selected </if> >{$r_val.name}</option>
                    </foreach>
                </select>
            </td>
        </tr> -->
        <input type="hidden" name="role_id" value="{$user['role_id']}"/>

        <tr>
            <td class="tableleft">入职时间</td>
            <td>
                <input type="date" name="work_time" value="{$user['work_time']|date='Y-m-d',###}"/>
            </td>
        </tr>
        <!-- <tr>
            <td class="tableleft">状态</td>
            <td>
                <input type="radio" name="status" value="1" <if condition="$user['status'] eq 1"> checked </if> /> 启用
                <input type="radio" name="status" value="2" <if condition="$user['status'] eq 2"> checked </if> /> 禁用
            </td>
        </tr> -->
        <input type="hidden" name="status" value="{$user['status']}"/>

        <input type="hidden" value="{$user['reg_time']}" name="reg_time" />
        <tr>
            <td class="tableleft"></td>
            <td>
                <button type="button" class="btn btn-primary" type="button" id="add-user">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
            </td>
        </tr>
    </table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('User/Index')}";
        });
        $("#add-user").click(function () {
            data = $("#user-form").serialize();
            $.post(
                    "{:U('User/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('User/Index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });
    });
</script>

<include file="Public:footer" />